import java.util.ArrayList;

import com.golden.gamedev.GameEngine;


public class Replay extends StateGameObject{
	private StateTable myTable;
	private State currentState; 
	private StateTableFileManager fileManager;
	private long totalElapsedTime; 
	public Replay(GameEngine e) {
		super(e);
	}

	@Override
	public void initResources() {
		fileManager = new StateTableFileManager();
		//fileManager.resumePlayFromFile(StateGameObject sgo, String name);
	}
	public void setTable(StateTable table)
	{
		myTable = table;
		currentState = myTable.getTable().get(0);
	}
	@Override
	public void updateGame(long elapsedTime) {
		updateFromTable(elapsedTime);
		
	}
	public void updateFromTable(long elapsedTime)
	{
		updateFromState(currentState);
		if(currentState.getTime()-elapsedTime < 0)
		{
			ArrayList<State> list = myTable.getTable();
			currentState = list.get(list.indexOf(currentState) + 1);
		}
	}

}
